#ifndef CUSTOMSLIDER_H
#define CUSTOMSLIDER_H

#include <QSlider>
#include <QPainter>

class CustomSlider : public QSlider
{
    Q_OBJECT
public:
    explicit CustomSlider(QWidget *parent = nullptr);
    
    void setFloatRange(float min, float max);
    void setFloatValue(float value);
    float floatValue() const;
    void setShowValue(bool show) { m_showValue = show; }

protected:
    void paintEvent(QPaintEvent *ev) override;
signals:

    void floatValueChanged(float value);

private:
    int scaleToInt(float value) const;
    float scaleToFloat(int value) const;
    float m_min = 0.0f;
    float m_max = 100.0f;
    bool m_showValue = false;
    static constexpr int SCALE_FACTOR = 10;  // 保留一位小数
};

#endif // CUSTOMSLIDER_H 
